<template>
	<view class="">
		<scroll-view scroll-y="true" >
			<view class="topBox">
				<view class="coinCount">
					<view class="num">
						{{iconInfo.day}}
					</view>
					<view class="text">
						参与天数
					</view>
				</view>
				<view class="countBox">
					<view class="countItem">
						<view class="num">
							{{iconInfo.totalIncome}}
						</view>
						<view class="text">
							累计收益(元)
						</view>
					</view>
					<view class="b">
						
					</view>
					<view class="countItem">
						<view class="num">
							{{iconInfo.yesterIncome}}
						</view>
						<view class="text">
							当月收益(元)
						</view>
					</view>
				</view>
			</view>
			
			<view class="profit_top">
				<picker mode="date" fields="month"  :end="newDay"   @change="clickTab">
					<view :class=" 'profit_b active'" >
						{{day}}
					</view>
				</picker>
				<!-- <view  :class="day==15?'profit_b active':'profit_b'" @click="clickTab(15)">
					15天
				</view>
				<view  :class="day==30?'profit_b active':'profit_b'" @click="clickTab(30)">
					30天
				</view> -->
			</view>
			<view class="content">
						
						<view class="charts-box">
							<qiun-data-charts type="area" :opts="opts" :chartData="chartData" />
						</view>
				<!-- 		<view class="profit_view">
							<view class="g">参与天数{{iconInfo.day}}天</view>
							<view class="r">昨日收益{{iconInfo.yesterIncome}}</view>
							<view class="r">累计收益{{iconInfo.totalIncome}}</view>
						</view> -->
						<view class="profit_list">
							<view class="profit_title">
								收益明细
							</view>
							<view class="profit_itemt">
								<view>日期</view>
								<view>95峰值</view>
								<view>收益</view>
							</view>
							<view class="profit_item" v-for="(item,index) in iconInfo.list" :key="index" >
								<view>{{item.date}}</view>
								<view>{{item.flow}}</view>
								<view >
									<view style="color: #FF0000;">+{{item.money}}</view>
									<!-- <image src="/static/newProject/equipment/icon_r.png" mode=""></image> -->
								</view>
							</view>
						</view>
					</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				chartData: {},
				opts: {
					color: ["#FC8452","#00aa90", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272",  "#9A60B4",
						"#ea7ccc"
					],
					padding: [15, 15, 0, 15], // 图位置
					enableScroll: false,
					xAxis: {
						disableGrid: true,
						labelCount: 4, //设置显示个数
						format: 'formatterTime1'
					},
					dataLabel: false, // 数据显示
					legend: false,
					dataPointShape: false, // 圆点显示
					yAxis: {
						gridType: "dash",
						dashLength: 2
					},
					extra: {
						area: {
							type: "straight",
							opacity: 0.2,
							addLine: true,
							width: 2,
							gradient: false,
							activeType: "hollow"
						}
					}
				},
				iconInfo:{
					
				},
				lineData:[],
				day:"",
				newDay:"",
				sn:'',
				
			};
		},
		watch:{
			day(val){
				console.log(val)
				this.day =val
				this.$forceUpdate()
			}
		},
		onLoad(option){
			this.sn = option.name
			this.day = this.$fun.getYMD()
			this.newDay = this.$fun.getYMD()
		},
		onShow() {
			//模拟从服务器获取数据
			this.getServerData()
		},
		methods: {
			onUecharts(){
				let res = {
					categories: this.lineData.date,
					series: [{
							name: "收益",
							data: this.lineData.flow
						},
					]
				};
				this.chartData = JSON.parse(JSON.stringify(res));
			},
			
			clickTab(e){
				this.day = e.detail.value
				this.chartsDataLine1=[]
				this.getServerData()
			},
			jump(url){
				this.$fun.jump(url)
			},
			getServerData() {
				let data = []
				this.$fun.ajax.post('butt/buttIncome',{day:this.day,sn:this.sn}).then(res=>{
					this.iconInfo=res.data
						this.lineData = res.data.kline
						this.onUecharts()
				})
			}
		}
	};
</script>

<style lang="scss">
	page{
		background: #EEEEEE;
	}
	.topBox{
		background: #2a80f7;
		height: 300rpx;
		overflow: hidden;
		.coinCount{
			margin-top: 50rpx;
			text-align: center;
			.num{
				font-size: 54rpx;
				font-family: Bahnschrift;
				font-weight: 600;
				color: #FFFFFF;
			}
			.text{
				font-size: 24rpx;
				font-family: Adobe Heiti Std;
				font-weight: normal;
				color: #EEEEEE;
			}
		}
		.countBox{
			margin-top: 50rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.countItem{
				width: calc((100% - 2rpx)/2);
				text-align: center;
				.num{
					font-size: 40rpx;
					font-family: Bahnschrift;
					font-weight: 600;
					color: #FFFFFF;
				}
				.text{
					font-size: 24rpx;
					font-family: Adobe Heiti Std;
					font-weight: normal;
					color: #EEEEEE;
				}
			}
			.b{
				width: 2rpx;
				height: 60rpx;
				background: #FFFFFF;
				opacity: 0.33;
			}
		}
	}
	.profit_top {
		margin: 32rpx 0;
		display: flex;
		justify-content: space-around;
		background: #EEEEEE;
		.profit_b {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 220rpx;
			height: 80rpx;
			background: #2a80f7;
			border-radius: 10rpx;
			font-size: 30rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: #222222;
		}
	
		.active {
			background: 2a80f7;
			color: #FFFFFF;
		}
	}
	.content {
		display: flex;
		flex-direction: column;
		flex: 1;
		// background: #FFFFFF;

		.charts-box {
			width: calc(100% - 18rpx*2);
			height: 634rpx;
			margin: 0  auto;
			padding-right: 30rpx;
			background: #FFFFFF;
			border-radius: 12rpx;
		}

		.profit_view {
			height: 100rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background: #FFFFFF;
			padding: 0 30rpx;
			box-sizing: border-box;
			font-size: 30rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: #333333;

			.g {
				color: #333333;
			}

			.r {
				color: #5990FF;
			}
		}

		.profit_list {
			margin: 24rpx 18rpx;
			background: #FFFFFF;
			border-radius: 12rpx;
			.profit_title {
				padding-top: 32rpx;
				padding-left: 32rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #333333;
			}

			.profit_itemt {
				margin-top: 30rpx;
				height: 80rpx;
				// background: #F6F6F6;
				display: flex;
				justify-content: space-between;
				border-radius: 10rpx 10rpx 0rpx 0rpx;
				align-items: center;

				view{
					width: 25%;
					text-align: center;
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #999999;
					display: flex;
					justify-content: center;
				}
				view:not(:nth-child(1)){
					text-align: left;
				}
			}

			.profit_item {
				height: 100rpx;
				// background: #FFFFFF;
				display: flex;
				justify-content: space-between;
				border-radius: 10rpx 10rpx 0rpx 0rpx;
				align-items: center;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
				view{
					display: flex;
					justify-content: space-between;
					width: 25%;
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					color: #FF0000;
					text-align: center;

					image{
						width: 14rpx;
						height: 24rpx;
						margin-right: 20rpx;
					}
				}
				view:nth-child(1){
					width: 25%;
					color: #333333;
					display: flex;
					justify-content: center;
					text-align: center;
				}
				// view:last-child(){
				// 	width: 25%;
				// 	color: #333333;
				// 	display: flex;
				// 	justify-content: center;
				// }
				view:not(:nth-child(1)){
					width: 25%;
					text-align: left;
					color: #FE5102;
					    display: flex;
					    justify-content: center;
				}
			}
		}
	}
</style>
